﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_Linkman_AddCustomLinkman]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_Linkman_AddCustomLinkman];
GO
CREATE PROCEDURE [dbo].[sproc_Linkman_AddCustomLinkman]
@Name            nvarchar(100),
@Gender            bit,
@UnitTelephone        nvarchar(50),
@Email            nvarchar(50),
@UnitAddress        nvarchar(200),
@UnitZip        nvarchar(50),
@FamilyAddress        nvarchar(200),
@FamilyZip        nvarchar(50),
@Mobile            nvarchar(100),
@FamilyTelephone    nvarchar(50),
@Memo            nvarchar(1000),
@Staffid        int,
@Age            nvarchar(50)
/*-------------------------------------------------
功能： 添加自定义联系人
参数：
@Name            姓名
@Gender            性别（1男0女）
@UnitTelephone        单位电话
@Email            email
@UnitAddress        单位地址
@UnitZip        单位邮编
@FamilyAddress        家庭地址
@FamilyZip        家庭邮编
@Mobile            手机
@FamilyTelephone    家庭电话
@Memo            备注
@Staffid        添加人id
@Age            年龄
-----------------------------------------------------*/
AS
    DECLARE @linkmanid INT

    INSERT INTO UDS_Linkman_CustomLinkman(
                        Name        ,
                        Age        ,        
                        Gender        ,        
                        UnitTelephone    ,    
                        Email        ,        
                        UnitAddress    ,
                        UnitZip        ,
                        FamilyAddress    ,
                        FamilyZip    ,
                        Mobile        ,
                        FamilyTelephone    ,
                        Memo
                        )
    VALUES(
                        @Name        ,    
                        @Age        ,    
                        @Gender        ,        
                        @UnitTelephone    ,    
                        @Email        ,        
                        @UnitAddress    ,
                        @UnitZip    ,
                        @FamilyAddress    ,
                        @FamilyZip    ,
                        @Mobile        ,
                        @FamilyTelephone,
                        @Memo
                            )
    SET @linkmanid = @@IDENTITY

    INSERT INTO UDS_Linkman_LinkmanList(Staff_ID,LinkmanType,LinkmanID)
    VALUES(@staffid,3,@linkmanid)
    RETURN(@linkmanid)